// ( function(){

//     var eventsource = new EventSource( "/serversent" );
//     eventsource.addEventListener( "message", function( event ){
//         console.log( event );
//     } );
// } )()


var app = angular.module('sse', [])
.controller('statCtrl' , function ($scope) {

    // the last received msg
    $scope.msg = {};

    // handles the callback from the received event
    var handleCallback = function (msg) {
        $scope.$apply(function () {
            $scope.msg = JSON.parse(msg.data)
        });
    }

    var source = new EventSource('/serversent');
    source.addEventListener('message', handleCallback, false);
});
